#pragma once

#include "FrameOperation.h"

class CVariableDescription;

class CLoadVariableAddressOperation : public IFrameOperation
{

public:
    //@InErrorToken might be nullptr
    //must be set if do not sure that the variable is assigned
    CLoadVariableAddressOperation(
        std::shared_ptr<CVariableDescription> InVariableDescription 
        ,std::shared_ptr<CScriptToken> InErrorToken=nullptr
        )
    {
        VariableDescription = InVariableDescription;
        LoadToken=InErrorToken;
    }

    virtual EFrameOperationType GetType() const override
    {
        return EFrameOperationType::LoadVariableAddress;
    }

    std::shared_ptr<CVariableDescription> GetVariable() const
    {
        return VariableDescription;
    }

    std::shared_ptr<CScriptToken> GetErrorToken() const
    {
        return LoadToken;
    }
protected:
    std::shared_ptr<CVariableDescription> VariableDescription;

    //the token that is used to load the variable address
    //used for error reporting
    std::shared_ptr<CScriptToken> LoadToken;
};
